// 定义系统业务Table Columns
import * as constants from 'src/AppConstants'
import utils from 'commons/utils'
import {StatusColumn, StatusFixedColumn} from './base_columns'

export const SysRoleColumns = [
    {
        title: '角色',
        key: 'name'
    },
    {
        title: '编码',
        key: 'code'
    },
    {
        title: '说明',
        key: 'description'
    },
    {
        title: '操作',
        key: 'action',
        align: 'center',
        width: 240,
        render (row, column, index) {
            return `<i-button type="text" size="small" icon="edit" @click="onEdit(${index})" ${constants.JUDGE_IS == row.type ? 'disabled' : ''}>编辑</i-button>
                     <i-button type="text" size="small" icon="trash-b" @click="onDelete(${index})" ${constants.JUDGE_IS == row.type ? 'disabled' : ''}>删除</i-button>`
        }
    }
]

export const SysUserColumns = [{
    title: '用户名',
    key: 'username',
    sortable: true
},
    {
        title: '姓名',
        key: 'realname'
    },
    {
        title: '性别',
        key: 'sex',
        align: 'center',
        width: 80,
        render(row, column, index) {
            return utils.getNameByCode(constants.SEX, row.sex)
        }
    },
    {
        title: '手机',
        key: 'phone',
        align: 'center'
    },
    {
        title: '最后登录时间',
        key: 'lastLoginTime',
        sortable: true,
        align: 'center',
        width: 160
    },
    {
        title: '最后登录IP',
        key: 'lastLoginIP',
        align: 'center',
        width: 160
    },
    StatusColumn,
    {
        title: '操作',
        key: 'action',
        align: 'center',
        width: 240,
        render (row, column, index) {
            return `<i-button type="text" size="small" icon="edit" @click="onEdit(${index})">编辑</i-button>
                     <i-button type="text" size="small" icon="key" @click="onEditPwd(${index})" ${utils.isUserSelf(row.id) ? 'disabled' : ''}>修改密码</i-button>`
        }
    }
]
